﻿using System.Collections.Generic;

namespace Common
{
    /// <summary>
    /// Name - MyHealthGoalConfigViewModel.cs
    /// Description - Encapsulates data from the user interface for the business layer
    /// Programmer - Matthew Mitchell
    /// Date coded - 11/27/2011
    /// Arguments - None
    /// Variables - None
    /// Files accessed by this code artifact - None
    /// Files changed by this code artifact - None
    /// I/O - None
    /// Error Handling - None
    /// Modifications -
    ///     1.0 - Initial coding
    /// Known Faults -
    ///     1.0 - None known
    /// </summary>
    public class MyHealthGoalConfigViewModel
    {
        private List<HealthGoal> changedHealthGoals;

        /// <summary>
        /// Initializes a new instance of the <see cref="MyHealthGoalConfigViewModel"/> class.
        /// </summary>
        public MyHealthGoalConfigViewModel()
        {
            changedHealthGoals = new List<HealthGoal>();
        }

        /// <summary>
        /// Gets or sets the health goals.
        /// </summary>
        /// <value>
        /// The health goals.
        /// </value>
        public IEnumerable<HealthGoal> HealthGoals { get; set; }

        /// <summary>
        /// Updates the health goal.
        /// </summary>
        /// <param name="id">The id.</param>
        /// <param name="selected">if set to <c>true</c> [selected].</param>
        public void UpdateHealthGoal(int id, bool selected)
        {
            foreach (var healthGoal in HealthGoals)
            {
                if (healthGoal.ID == id)
                {
                    if (healthGoal.Selected != selected)
                    {
                        healthGoal.Selected = selected;

                        changedHealthGoals.Add(healthGoal);
                    }

                    break;
                }
            }
        }

        /// <summary>
        /// Exposes changed health goals.
        /// </summary>
        /// <returns></returns>
        public IEnumerable<HealthGoal> ChangedHealthGoals()
        {
            return changedHealthGoals;
        }
    }
}
